#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Created by master on 2017/5/5

import requests


def download(keyword, page=1):
    header = {
        'Connection': 'keep-alive',
        'Cache-Control': 'max-age=0',
        'Upgrade-Insecure-Requests': '1',
        'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36',
        'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
        'Accept-Encoding': 'gzip, deflate, sdch',
        'Accept-Language': 'zh-CN,zh;q=0.8',
        'Referer': 'https://www.google.com/'
    }
    url = "http://weixin.sogou.com/weixin?type=2&s_from=input&query=" + keyword+"&page="+str(page)
    html = requests.get(url, headers=header, timeout=30).content
    print(html.decode("utf-8"))
    return html.decode("utf-8")
